<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<title>订单详情</title>
		[#include "/admin/include/head.htm"]
		<link href="${base}/resource/css/order.css" rel="stylesheet" type="text/css" />
		<script type="text/javascript" >
			$(function(){
				// Tab效果
				tabs = $("#tab").tabs("div.tabContent", {
					tabs: "input"
				});
			});
			
			//订单审核
			function audit(){
				jQuery.ligerDialog.confirm('确定审核订单吗?', function(confirm){
					if(confirm){
						$.ajax({
							url: base + '/admin/b2c/order/audit.jhtml',
				          	loading: '正在执行审核处理...',
				          	type: 'POST',
				          	data: { 
						  		orderNo : '${(order.orderNo)!""}'
						  	},
							dataType:'json',
				          	success: function (data) {
								if(data.type == 'SUCCESS'){
									LG.showSuccess('审核成功！');
									$("#auditButton")[0].disabled=undefined;
									window.location.reload();
								}else{
									LG.showError(data.content);
								}
						  	}
				      	});
					}
				});
			}
			
			//订单配货
			function pick(){
				$.ligerDialog.confirm(
					"是否要进行配货操作?", 
					function (confirm){
						if(confirm){
							$("#pickupForm").submit();
						}
	           		}
	           	);
			}
			
			//订单发货
			function shipping(){
				$.ligerDialog.open({
					title:"订单发货", height: 650,width:1250,
					url: base + '/admin/b2c/order/shipping.jhtml?orderId=${(order.id)!}',isResize: true,
					buttons: [
						{ text: '保存', onclick: function (item, dialog) { 
							//表单底部按钮 
							jQuery.ligerDialog.confirm('确定发货吗?', function(confirm){
								if(confirm){
									if(dialog.frame.save(item, dialog)){
										window.location.reload();
									}
								}
							});
						}},
						{ text: '取消', onclick: function (item, dialog) { dialog.hide();}}
					]
				});
			}
			
			//订单支付
			function payment(){
				$.ligerDialog.open({
					title:"订单支付", height: 500,width:1000,
					url: base + '/admin/b2c/order/payment.jhtml?orderId=${(order.id)!""}', isResize: true,
					buttons: [
						{ text: '确定', onclick: function (item, dialog) { 
							//表单底部按钮 
							var mainform = dialog.frame.document.getElementById("mainform");
							jQuery.ligerDialog.confirm('确定线下支付吗?', function(confirm){
								if(confirm){
									dialog.frame.f_saveForDialog($(mainform),function(){
										dialog.hide();
										window.location.reload();
									});
								}
							});
						}},
						{ text: '取消', onclick: function (item, dialog) {dialog.hide();}}
					]
				});
			}
			
			//订单完成
			function complete(){
				$.ligerDialog.confirm(
					"${message('admin.order.completeDialog')}", 
					function (confirm){
						if(confirm){
					 		$("#completeForm").submit();
					 	}
	           		}
	           	);
			}		
				
			//订单申请退货
			function reject(){
				$.ligerDialog.open({
	                height:700,width: 1200,title : '申请退款',
	                url: '${base}/admin/b2c/order/refund.jhtml?orderId=${(order.id)!}',
	                buttons: [
						{ text: '确定', onclick: function (item, dialog) { 
							var mainform = dialog.frame.document.getElementById("mainform");
							dialog.frame.f_saveForDialog($(mainform),function(){
								dialog.hide();
								window.location.reload();
							});
						}},
						{ text: '取消', onclick: function (item, dialog) {dialog.hide();}}
					]
	            });
			}
			
			function cancel(){
			  	jQuery.ligerDialog.confirm('确定取消订单吗?', function(confirm){
					if(confirm){
						$.ajax({
							url: base + '/admin/b2c/order/cancel.jhtml',
				          	loading: '正在取消中...',
				          	type: 'POST',
				          	data: { 
						  		orderNo : '${(order.orderNo)!""}'
						  	},
							dataType:'json',
				          	success: function (data) {
								if(data.type == 'SUCCESS'){
									LG.showSuccess('取消成功！');
									$("#cancelButton")[0].disabled=undefined;
									window.location.reload();
								}else{
									LG.showError(data.content);
								}
						  	}
				      	});
					}
				});
			}
				
		</script>
		<style>
			.table tr th, .table tr td{
				text-align: center
			}
		</style>
	</head>
	<body>
		<form action="updateOrder.jhtml" method="post" id="mainform" class="validate">
			<input id="orderDomain_Id" name="id" value="${(order.id)!''}"  type="hidden">
			<div style="padding:10px;text-align:right;">
				[#assign isDisabled = order.isExpired || order.orderStatus = "tradeFinished" ||  order.orderStatus = "tradeClosed"]
				
				[#--if !confirm?? || confirm]
					<input type="button" onclick="confirm()" title="确认后订单信息不能被修改"  class="button" value="确认" [#if isDisabled || order.orderStatus != "waitSellerApprove" ] disabled="disabled" [/#if]/>
				[/#if--]
				
				[#if !audit?? || audit]
					<input type="button" onclick="audit()" id="auditButton"class="button" value="审核"  [#if order.orderStatus != "waitSellerAudit" || isDisabled ]disabled="disabled"[/#if]/>
				[/#if]
				
				[#if !pick?? || pick]
				<input type="button" onclick="pick()" class="button" value="拣货"  [#if order.orderStatus != "waitSellerSendGoods" || order.allOrderItemToRefundAndFinished || order.shipStatus != "unpick" || isDisabled ]disabled="disabled"[/#if]/>
				[/#if]
				
				[#if !payment?? || payment]
				<input type="button" onclick="payment()" class="button" value="支付" [#if isDisabled || order.payStatus != "unpay"]disabled="disabled"[/#if]/>
				[/#if]
				
				[#if !shipping?? || shipping]
				<input type="button" onclick="shipping()" class="button" value="[#if order.shippings?has_content && !order.allShiped]补发货[#else]发货[/#if]"  [#if isDisabled ||  order.allShiped || order.shipStatus = "unpick"]disabled="disabled"[/#if]/>
				[/#if]
				
				[#if !complete?? || complete]
				<input type="button" onclick="complete()" class="button" value="完成"  [#if isDisabled]disabled="disabled"[/#if]/>
				[/#if]
				
				[#if !refund?? || refund]
				<input type="button" onclick="reject()" class="button" value="申请退货" [#if order.isExpired  || order.orderStatus == "tradeClosed"|| order.orderStatus == "waitBuyerConfirmGoods"  || order.orderStatus == "waitBuyerPay" ] disabled="disabled" [/#if]/>
				[/#if]
				
				[#if !cancel?? || cancel]
				<input type="button" onclick="cancel()" id="cancelButton" class="button"  value="取消"  [#if order.orderStatus = "tradeFinished" ||  order.orderStatus = "tradeClosed"  || (order.orderStatus != "waitBuyerConfirmOrder" && order.orderStatus != "waitBuyerPay")] disabled="disabled" [/#if]/>
				[/#if]
			</div>
			<ul class="tab" id="tab">
				<li>
					<input type="button" value="基本信息">
				</li>
				<li>
					<input type="button" value="商品信息">
				</li>
				<li>
					<input type="button" value="收退款记录">
				</li>
				<li>
					<input type="button" value="收发货记录">
				</li>
				<li>
					<input type="button" value="订单日志">
				</li>
			</ul>
			<div title="基本信息" class="tabContent">
				<div class="clearfix">
					<div style="float:left;">
						<table class="division">
							<thead>
								<tr>
									<td colspan="2">订单信息</td>
								</tr>
							</thead>
							<tr>
								<th>订单编号：</th>
								<td>${(order.orderNo)!''}</td>
							</tr>
							<tr>
								<th>创建日期：</th>
								<td>${order.createDate?string('yyyy-MM-dd HH:mm:ss')}</td>
							</tr>
							<tr>
								<th>订单状态：</th>
								<td>
									<span class="modifyState">
										${DictionaryUtils.getEnumName(order.orderStatus)}
										&nbsp;
										[#if order.isExpired][订单已过期][/#if]
									</span>
								</td>
							</tr>
							<tr>
								<th>支付状态：</th>
								<td><span>${DictionaryUtils.getEnumName(order.payStatus)}</span></td>
							</tr>
							<tr>
								<th>支付类型：</th>
								<td><span>${DictionaryUtils.getEnumName(order.payType)}</span></td>
							</tr>
							<tr>
								<th>发货状态：</th>
								<td><span>${DictionaryUtils.getEnumName(order.shipStatus)}</span></td>
							</tr>
							
							<tr>
								<th>有退货记录：</th>
								<td>
									[#if order.hasRefunded]
										[#if order.allOrderItemToRefundAndFinished]
											<span class="red">所有订单项已完成退换货</span>
										[#else]
                                            有
										[/#if]
									[#else]
										没有
									[/#if]
								</td>
							</tr>
							<tr>
								<th>订单总额：</th>
								<td id="totalCost">${currency(order.amount, true)}</td>
							</tr>
							<tr>
								<th>支付类型：</th>
								<td>${DictionaryUtils.getEnumName(order.payType)}</td>
							</tr>
							<tr>
								<th>支付方式：</th>
								<td>${(order.paymentTypeName)!'未支付'}</td>
							</tr>
							<tr>
								<th>余额：</th>
								<td> ${currency(order.deposit, true)} </td>
							</tr>
							<tr>
								<th>现金：</th>
								<td> ${currency(order.cash, true)} </td>
							</tr>
						</table>
					</div>
					<div style="float:left;">
						<table class="division">
							<thead>
								<tr>
									<td colspan="2">会员信息</td>
								</tr>
							</thead>
							<tr>
								<th>用户名：</th>
								<td>${(order.member.username)!''} </td>
							</tr>
							<tr>
								<th>姓名：</th>
								<td>${(order.member.name)!''}</td>
							</tr>
							<tr>
								<th>手机：</th>
								<td>${(order.member.mobile)!''}</td>
							</tr>
							<tr>
								<th>地区：</th>
								<td>${(order.member.area.full_name)!''}</td>
							</tr>
							<tr>
								<th>E-mail：</th>
								<td>${(order.member.email)!''}</td>
							</tr>
						</table>
						<div style="float:left;">
							<table class="division">
								<thead>
									<tr>
										<td colspan="2">收货人信息</td>
									</tr>
								</thead>
								<tr>
									<th>收货人：</th>
									<td>
										<span class="normalState">
											${(order.consignee)!}
										</span>
									</td>
								</tr>
								<tr>
									<th>联系电话：</th>
									<td>
										<span class="normalState">
											${(order.contact)!}
										</span>
									</td>
								</tr>
								<tr>
									<th>地区：</th>
									<td>
										${(order.areaName)!''}
									</td>
								</tr>
								<tr>
									<th>地址：</th>
									<td>
										${(order.address)!''}
									</td>
								</tr>
								<tr>
									<th>邮编：</th>
									<td>
										${(order.zipCode)!}
									</td>
								</tr>
							</table>
						</div>
					</div>
					<div style="float:left;">
						<table class="division">
							<thead>
								<tr>
									<td colspan="2">客户附言</td>
								</tr>
							</thead>
							<tr>
								<th>附言：</th>
								<td> 
									<textarea rows="10" cols="25" disabled="disabled">${(order.postscript)!}</textarea>
								</td>
							</tr>
						</table>
					</div>
				</div>
			</div>
			<div title="商品信息" class="tabContent" style="padding:10px;">
				<table class="inputTable" style="width:100%;">
					<tbody>
						<tr class="title">
							<th>商品编号</th>
							<th>商品名称</th>
							<th>批次号</th>
							<th>商品规格</th>
							<th>有效日期</th>
							<th>售价</th>
							<th>数量</th>
							<th>小计</th>
							<th>退款状态</th>
							<th>退款数量</th>
						</tr>
					</tbody>
					[#if order.orderItems?? && order.orderItems?size > 0]
						[#list order.orderItems as orderItem]
							<tr class="cc">
								<td>${orderItem.goods.code}</td>
								<td><a href="${(orderItem.goods.path)!}" target="_blank" style="color:blue">${orderItem.productName}</a></td>
								<td>${(orderItem.batch)!}</td>
								<td>${(orderItem.specification)!}</td>
								<td>[#if orderItem.validDate??]${orderItem.validDate?date}[/#if]</td>
								<td>${currency(orderItem.salePrice,true)}</td>
								<td>${(orderItem.quantity)!}</td>
								<td>${currency(orderItem.subtotal, true)}</td>
								<td>
									[#if order.hasRefunded && orderItem.refund??]
										${DictionaryUtils.getEnumName(orderItem.refund.refundStatus)}
									[#else]
										无退货记录
									[/#if]
								</td>

								<td>${(orderItem.refund.quantity)!0}</td>
							</tr>
						[/#list]
					[/#if]
				</table>
			</div>
			<div title="收退款记录" class="tabContent">
				<div class="tableform">
					<table style="width:100%;">
						<tr valign="top">
							<td style="width:50%;"><h4>付款单据列表</h4>
							<table class="inputTable" style="width:100%;">
								<thead>
									<tr>
										<th>单据日期</th>
										<th>支付金额</th>
										<th>支付方式</th>
										<th>支付类型</th>
									</tr>
								</thead>
								[#if order.vouchers??]
									[#list order.vouchers as voucher]
									<tr style="text-align:left;">
										<td>${voucher.createDate?datetime}</td>
										<td>${currency(voucher.amount,true)}</td>
										<td>${(voucher.paymentMethod)!}</td>
										<td>${DictionaryUtils.getEnumName(voucher.payType)}</td>
									</tr>
									[/#list]
								[/#if]
							</table></td>
							<td><h4>退款单据列表</h4>
							<table class="inputTable" style="width:100%;">
								<thead>
									<tr>
										<th>单据日期</th>
                                        <th>单据编号</th>
                                        <th>退款商品</th>
                                        <th>数量</th>
										<th>退款金额</th>
										<th>状态</th>
									</tr>
								</thead>
								[#if order.orderItems?? && order.orderItems?has_content]
									[#list order.orderItems as item]
									[#if item.refund??]
									[#assign  refund = item.refund]
									<tr style="text-align:left;">
										<td>${refund.createDate?datetime}</td>
										<td>${refund.refundNo}</td>
										<td>${refund.productName}</td>
										<td>${refund.quantity}</td>
										<td>${(refund.amount)!''}</td>
										<td>${message("RefundStatus."+refund.refundStatus)}</td>
									</tr>
									[/#if]
									[/#list]
								[/#if]
							</table></td>
						</tr>
					</table>
				</div>
			</div>
			<div title="发货记录" class="tabContent">
				<div class="tableform">
					<table style="width:100%;">
						<tr valign="top">
							<td style="width:50%;"><h4>发货单据列表</h4>
							<table class="inputTable" style="width:100%;">
								<thead>
									<tr>
										<th width="20%">建立日期</th>
										<th width="20%">发货单号</th>
										<th width="20%">物流单号</th>
										<th width="10%">物流费用</th>
										<th width="10%">收件人</th>
										<th width="">备注</th>
									</tr>
								</thead>
								[#if order.shippings?? && order.shippings?size > 0]
									[#list order.shippings as shipping]
									<tr style="text-align:left;">
										<td>${(shipping.createDate?string('yyyy-MM-dd HH:mm:ss'))!''}</td>
										<td>${(shipping.sendSn)!}</td>
										<td>${(shipping.logisticsNo)!}</td>
										<td>${currency(shipping.shipFee,true)}</td>
										<td>${(shipping.receiver)!}</td>
										<td>${(shipping.remarks)!}</td>
									</tr>
									[/#list]	
								[/#if]
							</table></td>
						</tr>
					</table>
				</div>
			</div>

			<div title="订单日志" class="tabContent" style="padding:10px;">
				<table class="inputTable" style="width:100%;">
					<tbody>
						<tr class="title">
							<th>类型</th>
							<th>操作员</th>
							<th>操作员类型</th>
							<th>内容</th>
							<th>创建日期</th>
						</tr>
					</tbody>
					[#if order.orderLogs??]
						[#list order.orderLogs as orderLog]
						<tr class="title">
							<td>${DictionaryUtils.getEnumName(orderLog.logType)}</td>
							<td>${orderLog.operator}</td>
							<td>${orderLog.operatorType}</td>
							<td>${orderLog.logText}</td>
							<td>${orderLog.createDate?string('yyyy-MM-dd HH:mm:ss')}</td>
						</tr>
						[/#list]
					[/#if]
				</table>
			</div>
		</form>
		<form id="confirmForm" action="confirm.jhtml" method="post">
			<input type="hidden" name="orderId" value="${order.id}" />
		</form>
		<form id="pickupForm" action="pickup.jhtml" method="post">
			<input type="hidden" name="orderId" value="${order.id}" />
		</form>
		<form id="completeForm" action="complete.jhtml" method="post">
			<input type="hidden" name="orderId" value="${order.id}" />
		</form>
		<form id="cancelForm" action="cancel.jhtml" method="post">
			<input type="hidden" name="orderId" value="${order.id}" />
		</form>
	</body>
</html>